<template>
	<view class="content">
		<view class="card-list">
			<view class="card-list-li  flex" @click="on(item)" :class="[item.is_default == 1 ? 'active' : '']"  :key="index" v-for="(item,index) in items">
				<view class="card-list-images ">
					<image :src="item.logo" class="card-list-image" mode=""></image>
				</view>
				<view class="card-list-inner">
					<text class="card-list-name">
						{{item.name}}
					</text>
					<text>
						{{item.card_no}} 储蓄卡
					</text>
				</view>
			</view>
		</view>
		<view class="foot" @click="openCard">
			添加银行卡
		</view>
	</view>
</template>

<script>
	import {
        mapState,
        mapMutations
    } from 'vuex'
	
	export default {
		computed: {
            ...mapState(['token'])
        },
		data() {
			return {
				items: [],
			}
		},
		onShow() {
			this.getlist()
		},
		methods: {
			...mapMutations(['getNetworkType','vuexRequest']),
			getlist() {
				this.vuexRequest({
					url: '/api/v2/member/bank/index?access-token=' + this.token,
					method: 'GET',
					data: {},
					success: (res) => {
						
						this.items = res.data.data.list
					},
					fail: (err)  => {
						uni.showToast({
							title: err.data.message,
							position:'bottom'
						})
					},
				})	
			},
			openCard() {
				uni.navigateTo({
					url: '/pages/wallet/card/card'
				});
			},
			on(item) {
				this.vuexRequest({
					url: '/api/v2/member/bank/'+item.id+'?access-token=' + this.token,
					method: 'PUT',
					data: {is_default:1},
					success: (res)  => {
						//
						this.getlist()
					},
					fail: (err)  => {
						uni.showToast({
							title: err.data.message,
							position:'bottom'
						})
					},
				})	
			}
		}
	}
</script>

<style>
	.mt1{
		margin: 20upx  0 0 0;
	}
	.flex{
		display: -webkit-box;
		display: -webkit-flex;
		display: -ms-flexbox;
		display: flex;
		-webkit-box-orient: horizontal;
		-webkit-box-direction: normal;
		-webkit-flex-direction: row;
		-ms-flex-direction: row;
		flex-direction: row;
		-webkit-box-pack: justify;
		-webkit-justify-content: space-between;
		-ms-flex-pack: justify;
		justify-content: space-between;
		-webkit-box-align: center;
		-webkit-align-items: center;
		-ms-flex-align: center;
		align-items: center;
	}
	.po{
		position: relative;
	}
	.po:after{
		position: absolute;
		z-index: 10;
		right: 0;
		bottom: 0;
		left: 0;
		height: 1px;
		content: '';
		-webkit-transform: scaleY(.5);
		-ms-transform: scaleY(.5);
		transform: scaleY(.5);
		background-color: #c8c7cc;
	}
	
	.foot{
		position: fixed;
		bottom: 0;
		color: #FFFFFF;
		width: 100%;
		height: 100upx;
		background: #f54336;
		text-align: center;
		line-height: 100upx;
		z-index: 20;
	}
	.content{
		padding: 0 0 120upx 0;
	}
	.card-list-image{
		width: 100upx;
		height: 100upx;
	}
	.card-list-inner{
		width: 100%;
		padding: 0 0 0 20upx;
		font-size: 26upx;
		color: #5d5d5d;
	}
	.card-list-li {
		padding: 20upx 30upx;
		background: #FFFFFF;
		position: relative;
		margin: 20upx 0 0 0;
	}
	.card-list-name{
		display: block;
		color: #010101;
		font-size: 32upx;
	}
	.card-list-images{
		height: 100upx;
	}
	.card-list-li.active:before {
		font-size: 22px;
		position: absolute;
		content: '';
		top: 50%;
		right: 30upx;
		color: rgb(232, 62, 65);
		display: block;
		transform: translate(-50%,-48%) scale(.73);
		-webkit-transform: translate(-50%,-48%) scale(.73);
		width: 35upx;
		height: 15upx;
		border: solid 4upx rgb(232, 62, 65);
		border-left: none;
		border-bottom: none;
		transform:rotate(135deg);
		margin: -10upx 0 0 0;
	}
</style>
